package cn.tedu.store.config.minio;

import cn.tedu.store.config.minio.service.MinioTemplate;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * minio配置类
 */
@Configuration
public class MinioConfig {

    @Resource
    private MinioProperties properties;

    @Bean
    @ConditionalOnMissingBean(MinioTemplate.class)
    @ConditionalOnProperty(name = "minio.url")
    public MinioTemplate minioTemplate() {
        return new MinioTemplate(properties.getUrl(), properties.getAccessKey(), properties.getSecretKey());
    }
}
